﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using YWTSSys.BLL;
using YWTSSys.Library;
using YWTSSys.Model;
using System.Text;

namespace YWTSSys.Web.MachineSys.YWTSWeb.gl
{
    public partial class CustomerGroupMasterListaspx : PageBase
    {
        protected override Permission[] PowerKey
        {
            get
            {
                return new Permission[] { Permission.查看, Permission.修改, Permission.新增, Permission.删除 };
            }
        }
        protected override string DWZRef
        {
            get
            {
                return "CustomerGroupMasterListaspx";
            }


        }

        protected void Page_Load(object sender, EventArgs e)
        {
            // Response.Write(GetFolderTree(0));
        }
        /// <summary>
        /// '''营业一部'',''风险部'''
        /// </summary>
        /// <returns></returns>
      
        protected string GetFolderTree(int ParFolderID)
        {
            List<CustomerGroupInfo> listArea = CustomerGroupController.GetAllArea();
            if (listArea.Count <= 0)
                return "";

            /// <ul><li><a href="JSDWF/JSDWFFolderPageList.aspx?ParFolderID=1" target="ajax" rel="jbsxBox">尿检</a></li></ul>
            StringBuilder sb = new StringBuilder();
            sb.Append("<ul>");
            foreach (CustomerGroupInfo itm in listArea)
            {
                sb.Append("<li>");
                sb.AppendFormat("<a href=\"YWTSWeb/GL/CustomerGroupGroupList.aspx?AreaName={0}\" target=\"ajax\" rel=\"CustomerGroupGroupList\">{1}</a>", HttpUtility.UrlEncode(itm.分组标志), itm.分组标志);
                //sb.Append(itm.分组标志);
                sb.Append(GetGrouppTree(itm.分组标志));

                sb.Append("</li>");
            }
            sb.Append("</ul>");

            return sb.ToString();
        }

        protected string GetGrouppTree(string areaName)
        {
            DataTable listArea = CustomerGroupController.GetAllGroupByArea(areaName);
            if (listArea.Rows.Count <= 0)
                return "";

            /// <ul><li><a href="JSDWF/JSDWFFolderPageList.aspx?ParFolderID=1" target="ajax" rel="jbsxBox">尿检</a></li></ul>
            StringBuilder sb = new StringBuilder();
            sb.Append("<ul>");
            foreach (DataRow itm in listArea.Rows)
            {
                sb.Append("<li>");
               // sb.AppendFormat("<a href=\"YWTSWeb/GL/CustomerGroupGroupList.aspx?AreaName={0}\" target=\"ajax\" rel=\"CustomerGroupGroupList\">{1}</a>", HttpUtility.UrlEncode(itm.分组标志), itm.分组标志);
                sb.Append("<a href=\"#\">"+itm["分组标志"].ToString()+"</a>");
                sb.Append("</li>");
            }
            sb.Append("</ul>");

            return sb.ToString();
        }
    }
}